{% extends 'base.html' %}

{% block title %}
  货币管理 - 数据管理系统
{% endblock %}

{% block breadcrumb %}
  <li class="breadcrumb-item active" aria-current="page">货币管理</li>
{% endblock %}

{% block content %}
  <div class="d-flex justify-content-between align-items-center mb-4">
    <h2 class="page-header">货币列表</h2>
    {% if is_admin %}
      <a href="{{ url_for('add_currency') }}" class="btn btn-primary"><i class="bi bi-plus-lg"></i> 添加货币</a>
    {% endif %}
  </div>

  <div class="table-responsive">
    <table class="table table-striped table-hover">
      <thead class="table-light">
        <tr>
          <th>代码</th>
          <th>符号</th>
          <th>中文名称</th>
          <th>英文名称</th>
          <th>本地名称</th>
          <th>状态</th>
          {% if is_admin %}
            <th>操作</th>
          {% endif %}
        </tr>
      </thead>
      <tbody>
        {% for currency in currencies %}
          <tr>
            <td>
              <strong>{{ currency.code }}</strong>
            </td>
            <td>{{ currency.symbol }}</td>
            <td>{{ currency.name_cn }}</td>
            <td>{{ currency.name_en }}</td>
            <td>{{ currency.name_local or '-' }}</td>
            <td>
              {% if currency.is_active %}
                <span class="badge bg-success">启用</span>
              {% else %}
                <span class="badge bg-secondary">禁用</span>
              {% endif %}
            </td>
            {% if is_admin %}
              <td class="action-buttons">
                <div class="d-flex gap-2">
                  <a href="{{ url_for('edit_currency', id=currency.id) }}" class="btn btn-sm btn-outline-primary"><i class="bi bi-pencil"></i> 编辑</a>
                  <button type="button" class="btn btn-sm btn-outline-danger" onclick="if(confirm('确定删除货币 {{ currency.code }} 吗?')) window.location='{{ url_for('delete_currency', id=currency.id) }}'"><i class="bi bi-trash"></i> 删除</button>
                </div>
              </td>
            {% endif %}
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
{% endblock %}
